﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR40Response", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR40Response))]
    public class RR40ResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR40Response clazz;
        
        public RR40ResponseSerializer(IRR40Response clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("veakood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Veakood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("veatekst");
            if (clazz.Veatekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Veatekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Veatekst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("isik");
            if (clazz.Isik!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute(">>>RR40Response>isik>isik", "http://producers.rr.xtee.riik.ee/producer/rr", clazz.Isik.Count);
                for (int x = 0; ((clazz.Isik != null) 
                            && (x < clazz.Isik.Count)); x = (x + 1)) {
                    if (clazz.Isik[x]!=null) {
                        Writer.WriteStartElement("isik");
                        global::Xtee.Core.SerializationMetadata metaIsik = this.GetMetaData(clazz.Isik[x]);
                        Writer.WriteTypeAttribute(metaIsik.TypeQualifiedName.Namespace, metaIsik.TypeQualifiedName.Name);
                        metaIsik.NewSerializer(clazz.Isik[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isik");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("suhe");
            if (clazz.Suhe!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute(">>>RR40Response>suhe>suhe", "http://producers.rr.xtee.riik.ee/producer/rr", clazz.Suhe.Count);
                for (int x = 0; ((clazz.Suhe != null) 
                            && (x < clazz.Suhe.Count)); x = (x + 1)) {
                    if (clazz.Suhe[x]!=null) {
                        Writer.WriteStartElement("suhe");
                        global::Xtee.Core.SerializationMetadata metaSuhe = this.GetMetaData(clazz.Suhe[x]);
                        Writer.WriteTypeAttribute(metaSuhe.TypeQualifiedName.Namespace, metaSuhe.TypeQualifiedName.Name);
                        metaSuhe.NewSerializer(clazz.Suhe[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Suhe");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="veakood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR40Response>veakood");
                }
                clazz.Veakood = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("veakood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR40Response>veakood", Reader.LocalName);
            }
            if (Reader.LocalName=="veatekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR40Response>veatekst");
                }
                clazz.Veatekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("veatekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR40Response>veatekst", Reader.LocalName);
            }
            if (Reader.LocalName=="isik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR40Response>isik");
                }
                clazz.Isik = new System.Collections.Generic.List<RR40Response.IIsikType>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("isik");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "isik")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>RR40Response>isik>isik");
                        }
                        global::Xtee.Core.SerializationMetadata metaIsik = this.GetMetaData<RR40Response.IIsikType>(Reader, ">>>RR40Response>isik>isik", "http://producers.rr.xtee.riik.ee/producer/rr");
                        RR40Response.IIsikType item = metaIsik.NewEntity<RR40Response.IIsikType>();
                        clazz.Isik.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("isik");
                            metaIsik.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR40Response>isik", Reader.LocalName);
            }
            if (Reader.LocalName=="suhe") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR40Response>suhe");
                }
                clazz.Suhe = new System.Collections.Generic.List<RR40Response.ISuheType>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("suhe");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "suhe")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>RR40Response>suhe>suhe");
                        }
                        global::Xtee.Core.SerializationMetadata metaSuhe = this.GetMetaData<RR40Response.ISuheType>(Reader, ">>>RR40Response>suhe>suhe", "http://producers.rr.xtee.riik.ee/producer/rr");
                        RR40Response.ISuheType item = metaSuhe.NewEntity<RR40Response.ISuheType>();
                        clazz.Suhe.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("suhe");
                            metaSuhe.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR40Response>suhe", Reader.LocalName);
            }
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>>RR40Response>isik>isik", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR40Response.IsikType))]
        public class IsikTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected RR40Response.IIsikType clazz;
            
            public IsikTypeSerializer(RR40Response.IIsikType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                Writer.WriteStartElement("isik.Perenimi");
                if (clazz.IsikPerenimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikPerenimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikPerenimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Eesnimi");
                if (clazz.IsikEesnimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikEesnimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikEesnimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Sugu");
                if (clazz.IsikSugu!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikSugu))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikSugu");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Synniaeg");
                if (clazz.IsikSynniaeg!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikSynniaeg))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikSynniaeg");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Staatus");
                if (clazz.IsikStaatus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikStaatus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikStaatus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.EestiAadress");
                if (clazz.IsikEestiAadress!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikEestiAadress))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikEestiAadress");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.DokumendiTyyp");
                if (clazz.IsikDokumendiTyyp!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikDokumendiTyyp))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikDokumendiTyyp");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.DokumendiSeeria");
                if (clazz.IsikDokumendiSeeria!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikDokumendiSeeria))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikDokumendiSeeria");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.DokumendiNumber");
                if (clazz.IsikDokumendiNumber!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikDokumendiNumber))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikDokumendiNumber");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.DokumendiValjastKuup");
                if (clazz.IsikDokumendiValjastKuup!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikDokumendiValjastKuup))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikDokumendiValjastKuup");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.DokumendiKehtivuseAlgus");
                if (clazz.IsikDokumendiKehtivuseAlgus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikDokumendiKehtivuseAlgus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikDokumendiKehtivuseAlgus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.DokumendiKehtivuseLopp");
                if (clazz.IsikDokumendiKehtivuseLopp!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikDokumendiKehtivuseLopp))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikDokumendiKehtivuseLopp");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.DokumendiStaatus");
                if (clazz.IsikDokumendiStaatus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikDokumendiStaatus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikDokumendiStaatus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Rahvus");
                if (clazz.IsikRahvus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikRahvus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikRahvus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Emakeel");
                if (clazz.IsikEmakeel!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikEmakeel))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikEmakeel");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Haridus");
                if (clazz.IsikHaridus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikHaridus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikHaridus");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("isik.Tegevusala");
                if (clazz.IsikTegevusala!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikTegevusala))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikTegevusala");
                }
                Writer.WriteEndElement();
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
                if (Reader.LocalName=="isik.Perenimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.Perenimi");
                    }
                    clazz.IsikPerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Perenimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.Perenimi", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Eesnimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.Eesnimi");
                    }
                    clazz.IsikEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Eesnimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.Eesnimi", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Sugu") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.Sugu");
                    }
                    clazz.IsikSugu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Sugu")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.Sugu", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Synniaeg") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.Synniaeg");
                    }
                    clazz.IsikSynniaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Synniaeg")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.Synniaeg", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Staatus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.Staatus");
                    }
                    clazz.IsikStaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Staatus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.Staatus", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.EestiAadress") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.EestiAadress");
                    }
                    clazz.IsikEestiAadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.EestiAadress")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.EestiAadress", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.DokumendiTyyp") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.DokumendiTyyp");
                    }
                    clazz.IsikDokumendiTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.DokumendiTyyp")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.DokumendiTyyp", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.DokumendiSeeria") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.DokumendiSeeria");
                    }
                    clazz.IsikDokumendiSeeria = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.DokumendiSeeria")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.DokumendiSeeria", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.DokumendiNumber") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.DokumendiNumber");
                    }
                    clazz.IsikDokumendiNumber = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.DokumendiNumber")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.DokumendiNumber", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.DokumendiValjastKuup") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.DokumendiValjastKuup");
                    }
                    clazz.IsikDokumendiValjastKuup = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.DokumendiValjastKuup")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.DokumendiValjastKuup", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.DokumendiKehtivuseAlgus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.DokumendiKehtivuseAlgus");
                    }
                    clazz.IsikDokumendiKehtivuseAlgus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.DokumendiKehtivuseAlgus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.DokumendiKehtivuseAlgus", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.DokumendiKehtivuseLopp") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.DokumendiKehtivuseLopp");
                    }
                    clazz.IsikDokumendiKehtivuseLopp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.DokumendiKehtivuseLopp")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.DokumendiKehtivuseLopp", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.DokumendiStaatus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.DokumendiStaatus");
                    }
                    clazz.IsikDokumendiStaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.DokumendiStaatus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.DokumendiStaatus", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Rahvus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.Rahvus");
                    }
                    clazz.IsikRahvus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Rahvus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.Rahvus", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Emakeel") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.Emakeel");
                    }
                    clazz.IsikEmakeel = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Emakeel")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.Emakeel", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Haridus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.Haridus");
                    }
                    clazz.IsikHaridus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Haridus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.Haridus", Reader.LocalName);
                }
                if (Reader.LocalName=="isik.Tegevusala") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>isik>isik>isik.Tegevusala");
                    }
                    clazz.IsikTegevusala = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isik.Tegevusala")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>isik>isik>isik.Tegevusala", Reader.LocalName);
                }
            }
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>>RR40Response>suhe>suhe", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR40Response.SuheType))]
        public class SuheTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected RR40Response.ISuheType clazz;
            
            public SuheTypeSerializer(RR40Response.ISuheType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                Writer.WriteStartElement("suhe.ssuhtetyyp");
                if (clazz.Suhessuhtetyyp!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Suhessuhtetyyp))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Suhessuhtetyyp");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.sIsikukood");
                if (clazz.SuhesIsikukood!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesIsikukood))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesIsikukood");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.sPerenimi");
                if (clazz.SuhesPerenimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesPerenimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesPerenimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.sEesnimi");
                if (clazz.SuhesEesnimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesEesnimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesEesnimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.sIsanimi");
                if (clazz.SuhesIsanimi!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesIsanimi))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesIsanimi");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.sEesti_aadress");
                if (clazz.SuhesEestiAadress!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesEestiAadress))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesEestiAadress");
                }
                Writer.WriteEndElement();
                Writer.WriteStartElement("suhe.sStaatus");
                if (clazz.SuhesStaatus!=null) {
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SuhesStaatus))).ToString());
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SuhesStaatus");
                }
                Writer.WriteEndElement();
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
                if (Reader.LocalName=="suhe.ssuhtetyyp") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>suhe>suhe>suhe.ssuhtetyyp");
                    }
                    clazz.Suhessuhtetyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.ssuhtetyyp")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>suhe>suhe>suhe.ssuhtetyyp", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.sIsikukood") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>suhe>suhe>suhe.sIsikukood");
                    }
                    clazz.SuhesIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.sIsikukood")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>suhe>suhe>suhe.sIsikukood", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.sPerenimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>suhe>suhe>suhe.sPerenimi");
                    }
                    clazz.SuhesPerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.sPerenimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>suhe>suhe>suhe.sPerenimi", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.sEesnimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>suhe>suhe>suhe.sEesnimi");
                    }
                    clazz.SuhesEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.sEesnimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>suhe>suhe>suhe.sEesnimi", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.sIsanimi") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>suhe>suhe>suhe.sIsanimi");
                    }
                    clazz.SuhesIsanimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.sIsanimi")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>suhe>suhe>suhe.sIsanimi", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.sEesti_aadress") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>suhe>suhe>suhe.sEesti_aadress");
                    }
                    clazz.SuhesEestiAadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.sEesti_aadress")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>suhe>suhe>suhe.sEesti_aadress", Reader.LocalName);
                }
                if (Reader.LocalName=="suhe.sStaatus") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RR40Response>suhe>suhe>suhe.sStaatus");
                    }
                    clazz.SuhesStaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("suhe.sStaatus")).Value;
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RR40Response>suhe>suhe>suhe.sStaatus", Reader.LocalName);
                }
            }
        }
    }
}
